<%@page import="net.groupme.search.SEARCH_CONFIGURATION"%>
<%@page import="net.groupme.gui.rendering.constants.RENDERING_CONSTANTS"%>
<script type="text/javascript" language="javascript"><!--
//Search stuff:

function toggleSearchResults(id){
	$('htmlSearchResult').hide();
	$('imageSearchResult').hide();
	$('avSearchResult').hide();
	$('rssSearchResult').hide();
	$('groupmeSearchResult').hide();
	$('resourceQueue').hide();
	$('htmlSearchResultTab').hide();
	$('imageSearchResultTab').hide();
	$('avSearchResultTab').hide();
	$('rssSearchResultTab').hide();
	$('groupmeSearchResultTab').hide();
	$('resourceQueueTab').hide();
	$(id).show();
	$(id + "Tab").show();
}

function showGroupResults(){
	$('groupmeSearchResultResources').hide();
	$('groupmeSearchResultGroups').show();
}

function showResourceResults(){
	$('groupmeSearchResultGroups').hide();
	$('groupmeSearchResultResources').show();
}

var problemWithGoogleAPI = 1;
/**
 * Searching for new Resources. This method is called, whenever clicks on the search-Button.
 * This method then passes the entered keyword and the search-engine-selection to the general
 * Search Engine Ajax Controller
 */ 
function searchForResources(){
    var problemMessage = "<span style='font-size:0.8em; font-style: italic'>Currently switched off. We are working on it and keep you up to date via our <a href='http://groupme.org/blog/'>blog</a>.</span>";
    if(problemWithGoogleAPI == 1){
		dwr.util.byId("rssSearchResult").innerHTML = problemMessage; 
    }else{
    	
		dwr.util.byId("rssSearchResult").innerHTML = "<img src='<%= request.getContextPath() + RENDERING_CONSTANTS.RELATIVE_PATH_OF_AJAX_LOADING_IMAGE %>'/>"
		 	+ "<span style='font-size:0.8em; font-style: italic'>searching...</span>";
    }
	dwr.util.byId("htmlSearchResult").innerHTML = "<img src='<%= request.getContextPath() + RENDERING_CONSTANTS.RELATIVE_PATH_OF_AJAX_LOADING_IMAGE %>'/>"
			+ "<span style='font-size:0.8em; font-style: italic'>searching...</span>";
	dwr.util.byId("imageSearchResult").innerHTML = "<img src='<%= request.getContextPath() + RENDERING_CONSTANTS.RELATIVE_PATH_OF_AJAX_LOADING_IMAGE %>'/>"
		+ "<span style='font-size:0.8em; font-style: italic'>searching...</span>";
	dwr.util.byId("avSearchResult").innerHTML = "<img src='<%= request.getContextPath() + RENDERING_CONSTANTS.RELATIVE_PATH_OF_AJAX_LOADING_IMAGE %>'/>"
			+ "<span style='font-size:0.8em; font-style: italic'>searching...</span>";
	dwr.util.byId("groupmeSearchResultGroups").innerHTML = "<img src='<%= request.getContextPath() + RENDERING_CONSTANTS.RELATIVE_PATH_OF_AJAX_LOADING_IMAGE %>'/>"
		+ "<span style='font-size:0.8em; font-style: italic'>searching...</span>";
	dwr.util.byId("groupmeSearchResultResources").innerHTML = "<img src='<%= request.getContextPath() + RENDERING_CONSTANTS.RELATIVE_PATH_OF_AJAX_LOADING_IMAGE %>'/>"
		+ "<span style='font-size:0.8em; font-style: italic'>searching...</span>";
//	dwr.util.byId("resourceQueue").innerHTML = "- not yet implemented -";
//	$('imageSearchResult').hide();
//	$('avSearchResult').hide();
//	$('rssSearchResult').hide();
//	$('groupmeSearchResult').hide();
//	$('resourceQueue').hide();
//	$('htmlSearchResult').show();
	var keywords = dwr.util.getValue("searchkeywordsinput");
	
	if(problemWithGoogleAPI == 1){
		// rss search
		DWRResourceAggregation.searchForResources(keywords, '<%= SEARCH_CONFIGURATION.SOURCE_RSSSEARCH%>', doNothing);
	}else{
		// rss search
		DWRResourceAggregation.searchForResources(keywords, '<%= SEARCH_CONFIGURATION.SOURCE_RSSSEARCH%>', searchForResourcesFinishedRSS);
	}
		
		// html search
		DWRResourceAggregation.searchForResources(keywords, '<%= SEARCH_CONFIGURATION.SOURCE_GOOGLE%>', searchForResourcesFinishedHTML);
		
		// youtube search
		DWRResourceAggregation.searchForResources(keywords, '<%= SEARCH_CONFIGURATION.SOURCE_YOUTUBE%>', searchForResourcesFinishedMM);
		
		// flickr search
		DWRResourceAggregation.searchForResources(keywords, '<%= SEARCH_CONFIGURATION.SOURCE_FLICKR%>', searchForResourcesFinishedImages);
		
		// GroupMe search
		DWRResourceAggregation.searchForResources(keywords, '<%= SEARCH_CONFIGURATION.SOURCE_GROUPME_GROUPS%>', searchForResourcesFinishedGM);
		DWRResourceAggregation.searchForResources(keywords, '<%= SEARCH_CONFIGURATION.SOURCE_GROUPME_RESOURCES%>', searchForResourcesFinishedGM2);
		$('disabledZone').style.visibility = 'hidden';
	
}

function doNothing(data){
	//do nothing..
}	
/**
 * Callback functions which are executed after search for resources. This methods
 * have to visualize each search result item.
 * @param searchResults an Array containing SearchResult instances
 */
var currOpendExp;
var isMouseDownOnSearchResult;
var manualClickIndicator;
function searchForResourcesFinishedHTML(searchResults){
	dwr.util.byId("htmlSearchResult").innerHTML = "";
	if (searchResults.length == 0) dwr.util.byId("htmlSearchResult").innerHTML = "<span style='font-size:0.8em; font-style: italic'>- sry, no results -</span>";	
	for (i=0; i<searchResults.length; i++){
		var htmlString = "";
		var actualID = searchResults[i].resultID;
		htmlString += "<div id='" + actualID + "'";
		if ((i%2)==0){ 
			htmlString += " class='searchResultT'";
		}
		else {
			htmlString += " class='searchResultB'";
		}
		htmlString += " style='position:relative;'"
		+ " onmousedown='mouseDownOnSearchResult()'"
		+ " onmouseup='mouseUpOnSearchResult(\"" + searchResults[i].url + "\")'"
		+ " onmouseout='mouseOutOfSearchResult()'"
		+ ">"
		+ "<a href='#'"
		+ " onmouseover='openhtmlPrevInit(this, \"" + searchResults[i].url + "\", \"" + actualID + "\")' "
		+ " onmouseout='mouseOutOfSearchResult()' "
		+ "id='iframetest' class='highslide'>"
		+ searchResults[i].name
		+ "</a>"
		+ "<div class='highslide-html-content' id='htmlPrev' style='padding:0'>"
		+ "<div class='highslide-move html-header' style='border: 0'>"
    	+ "<a href='#' onclick='return hs.close(this)' class='control'>Close</a>"
	    + "</div>"
		+ "<div class='highslide-body'></div>"
		+ "</div>"
		+ "</div>"
		+ "<hr style='color:#3399cc'/>";
		dwr.util.byId("htmlSearchResult").innerHTML += htmlString;
	}
}
function searchForResourcesFinishedImages(searchResults){
	dwr.util.byId("imageSearchResult").innerHTML = "";
	if (searchResults.length == 0) dwr.util.byId("imageSearchResult").innerHTML = "<span style='font-size:0.8em; font-style: italic'>- sry, no results -</span>";	
	for (i=0; i<searchResults.length; i++){
		var actualID = searchResults[i].resultID;
		dwr.util.byId("imageSearchResult").innerHTML += "<div id='" + actualID + "' class='searchResult'" 
		+ " style='position:relative; float:left; height:51px; width: 59px; overflow:hidden;"
		+ " margin-right:2px; margin-left:2px; margin-top:3px;"
		+ " background-image:url(" + searchResults[i].urlOfThumbnail + "); background-repeat:no-repeat;'"
		+ " onmousedown='mouseDownOnSearchResult()'"
		+ " onmouseup='mouseUpOnSearchResult(\"" + searchResults[i].url + "\")'"
		+ " onmouseout='mouseOutOfImageSearchResult()'"
		+ ">"
		+ "<a id='thumb" + actualID + "' class='highslide' style='display:block; width: 59px; height: 51px;'"
		+ " onmouseover='openImagePrevInit(this, \"" + searchResults[i].url + "\", \"" + actualID + "\")'>"
	//	+ "<img src='" + searchResults[i].urlOfThumbnail + "' border='0' width='59px' class='highslide'/>"
		+ "</a>"	
		+ "</div>";
	}
}
function searchForResourcesFinishedRSS(searchResults){
	dwr.util.byId("rssSearchResult").innerHTML = "";
	if (searchResults.length == 0) dwr.util.byId("rssSearchResult").innerHTML = "<span style='font-size:0.8em; font-style: italic'>- sry, no results -</span>";	
	for (i=0; i<searchResults.length; i++){
		var htmlString = "";
		var actualID = searchResults[i].resultID;
		htmlString += "<div id='" + actualID + "'";
		if ((i%2)==0){ 
			htmlString += " class='searchResultT'";
		}
		else {
			htmlString += " class='searchResultB'";
		}
		htmlString += " style='position:relative;'"
		+ " onmousedown='mouseDownOnSearchResult()'"
		+ " onmouseup='mouseUpOnSearchResult(\"" + searchResults[i].url + "\")'"
		+ " onmouseout='mouseOutOfSearchResult()'"
		+ ">"
		+ "<a href='#'"
		+ "onmouseover='openhtmlPrevInit(this, \"" + searchResults[i].url + "\", \"" + actualID + "\")' "
		+ "id='iframetest' class='highslide'>"
		+ searchResults[i].name
		+ "</a>"
		+ "<div class='highslide-html-content' id='htmlPrev' style='padding:0'>"
		+ "<div class='highslide-move html-header' style='border: 0'>"
    	+ "<a href='#' onclick='return hs.close(this)' class='control'>Close</a>"
	    + "</div>"
		+ "<div class='highslide-body'></div>"
		+ "</div>"
		+ "</div>"
		+ "<hr style='color:#3399cc'/>";
		dwr.util.byId("rssSearchResult").innerHTML += htmlString;
	}
}
var searchResultsGroups;
var searchResultsResources;
function searchForResourcesFinishedGM(searchResults){
	searchResultsGroups = searchResults;
	renderGroupSearchResults(0);
}

function renderGroupSearchResults(startIndex){
	dwr.util.byId("groupmeSearchResultGroups").innerHTML = "<span style='font-size:0.9em; font-weight: bold'>GroupMe! groups:</span>";
	if (searchResultsGroups.length == 0) dwr.util.byId("groupmeSearchResultGroups").innerHTML += "<br/><span style='font-size:0.8em; font-style: italic'>- no GroupMe! groups found -</span>";	
	for (i=startIndex; i<searchResultsGroups.length && i<startIndex+12; i++){
		var htmlString = "";
		var actualID = searchResultsGroups[i].resultID;
		htmlString += "<div id='" + actualID + "'";
		if ((i%2)==0){ 
			htmlString += " class='searchResultT'";
		}
		else {
			htmlString += " class='searchResultB'";
		}
		htmlString += " style='position:relative;'"
		+ " onmousedown='mouseDownOnSearchResult()'"
		+ " onmouseup='mouseUpOnSearchResult(\"" + searchResultsGroups[i].url + "\")'"
		+ " onmouseout='mouseOutOfSearchResult()'"
		+ ">"
		+ "<a href='#'"
		+ " onmouseover='openhtmlPrevInit(this, \"" + searchResultsGroups[i].url + "\", \"" + actualID + "\")' "
		+ "id='iframetest' class='highslide'>"
		+ searchResultsGroups[i].name
		+ "</a>"
		+ "<div class='highslide-html-content' id='htmlPrev' style='padding:0'>"
		+ "<div class='highslide-move html-header' style='border: 0'>"
    	+ "<a href='#' onclick='return hs.close(this)' class='control'>Close</a>"
	    + "</div>"
		+ "<div class='highslide-body'></div>"
		+ "</div>"
		+ "</div>"
		+ "<hr style='color:#3399cc'/>";
		dwr.util.byId("groupmeSearchResultGroups").innerHTML += htmlString;
	}
	if (startIndex==0 && startIndex+12<searchResultsGroups.length){
		dwr.util.byId("groupmeSearchResultGroups").innerHTML += "<div style='width: 100%; position:absolute; bottom:4px'>"
			+ "<p style='text-align: center;'>"
			+ "<a href='javascript:renderGroupSearchResults(" + (startIndex+12) + ")'>"
			+ "next</a></p></div>";
	}
	if (startIndex!=0 && startIndex+12<searchResultsGroups.length){
		dwr.util.byId("groupmeSearchResultGroups").innerHTML += "<div style='width: 100%; position:absolute; bottom:4px'>"
			+ "<p style='text-align: center;'>"
			+ "<a href='javascript:renderGroupSearchResults(" + (startIndex-12) + ")'>"
			+ "previous</a> - "
			+ "<a href='javascript:renderGroupSearchResults(" + (startIndex+12) + ")'>"
			+ "next</a></p></div>";
	}
	if (startIndex!=0 && startIndex+12>=searchResultsGroups.length){
		dwr.util.byId("groupmeSearchResultGroups").innerHTML += "<div style='width: 100%; position:absolute; bottom:4px'>"
			+ "<p style='text-align: center;'>"
			+ "<a href='javascript:renderGroupSearchResults(" + (startIndex-12) + ")'>"
			+ "previous</a></p></div>";
	}
}
function searchForResourcesFinishedGM2(searchResults){
	searchResultsResources = searchResults;
	renderResourceSearchResults(0);
}

function renderResourceSearchResults(startIndex){
	dwr.util.byId("groupmeSearchResultResources").innerHTML = "<span style='font-size:0.9em; font-weight: bold'>GroupMe! resources:</span>";
	if (searchResultsResources.length == 0) dwr.util.byId("groupmeSearchResultResources").innerHTML += "<br/><span style='font-size:0.8em; font-style: italic'>- no GroupMe! resources found -</span>";	
	for (j=startIndex; j<searchResultsResources.length && j<startIndex+12; j++){
		var htmlString = "";
		var actualID = searchResultsResources[j].resultID;
		htmlString += "<div id='" + actualID + "'";
		if ((j%2)==0){ 
			htmlString += " class='searchResultT'";
		}
		else {
			htmlString += " class='searchResultB'";
		}
		htmlString += " style='position:relative;'"
		+ " onmousedown='mouseDownOnSearchResult()'"
		+ " onmouseup='mouseUpOnSearchResult(\"" + searchResultsResources[j].url + "\")'"
		+ " onmouseout='mouseOutOfSearchResult()'"
		+ ">"
		+ "<a href='#'"
		+ "onmouseover='openhtmlPrevInit(this, \"" + searchResultsResources[j].url + "\", \"" + actualID + "\")'"
		+ "id='iframetest' class='highslide'>"
		+ searchResultsResources[j].name
		+ "</a>"
		+ "<div class='highslide-html-content' id='htmlPrev' style='padding:0'>"
		+ "<div class='highslide-move html-header' style='border: 0'>"
    	+ "<a href='#' onclick='return hs.close(this)' class='control'>Close</a>"
	    + "</div>"
		+ "<div class='highslide-body'></div>"
		+ "</div>"
		+ "</div>"
		+ "<hr style='color:#3399cc'/>";
		dwr.util.byId("groupmeSearchResultResources").innerHTML += htmlString;
	}
	if (startIndex==0 && startIndex+12<searchResultsResources.length){
		dwr.util.byId("groupmeSearchResultResources").innerHTML += "<div style='width: 100%; position:absolute; bottom:4px'>"
			+ "<p style='text-align: center;'>"
			+ "<a href='javascript:renderResourceSearchResults(" + (startIndex+12) + ")'>"
			+ "next</a></p></div>";
	}
	if (startIndex!=0 && startIndex+12<searchResultsResources.length){
		dwr.util.byId("groupmeSearchResultResources").innerHTML += "<div style='width: 100%; position:absolute; bottom:4px'>"
			+ "<p style='text-align: center;'>"
			+ "<a href='javascript:renderResourceSearchResults(" + (startIndex-12) + ")'>"
			+ "previous</a> - "
			+ "<a href='javascript:renderResourceSearchResults(" + (startIndex+12) + ")'>"
			+ "next</a></p></div>";
	}
	if (startIndex!=0 && startIndex+12>=searchResultsResources.length){
		dwr.util.byId("groupmeSearchResultResources").innerHTML += "<div style='width: 100%; position:absolute; bottom:4px'>"
			+ "<p style='text-align: center;'>"
			+ "<a href='javascript:renderResourceSearchResults(" + (startIndex-12) + ")'>"
			+ "previous</a></p></div>";
	}
}
function searchForResourcesFinishedMM(searchResults){
	dwr.util.byId("avSearchResult").innerHTML = "";
	if (searchResults.length == 0) dwr.util.byId("avSearchResult").innerHTML = "<span style='font-size:0.8em; font-style: italic'>- sry, no results -</span>";	
	for (i=0; i<searchResults.length; i++){
		var htmlString = "";
		var actualID = searchResults[i].resultID;
		htmlString += "<div id='" + actualID + "'";
		if ((i%2)==0){ 
			htmlString += " class='searchResultT'";
		}
		else {
			htmlString += " class='searchResultB'";
		}
		htmlString += " style='position:relative;'"
		+ " onmousedown='mouseDownOnSearchResult()'"
		+ " onmouseup='mouseUpOnSearchResult(\"" + searchResults[i].url + "\")'"
		+ ">"
		+ "<a href='#' id='iframetest' class='highslide'"
		+ " onmouseover='openMMPrevInit(this, \"" + actualID + "\")'"
		+ " onmouseout='mouseOutOfSearchResult()'>"
		+ searchResults[i].name
		+ "</a>"
		+ "<div class='highslide-html-content' id='" + actualID + "_content' style='width: 444px; max-width:840px; padding:0'>"
		+ "<div style='height:20px; padding: 2px; font-size: 0.6em;'>"
		+ "<a href='#' onclick='return hs.close(this)' class='control'>Close</a>"
		+ "</div>"
		+ "<div class='highslide-body' style='padding: 0 10px 10px 10px'>"

		+ "<object width='425' height='344'>"
		+ "<param name='movie' value='" + actualID + "'></param>"
		+ "<param name='allowFullScreen' value='true'></param>"
		+ "<param name='autostart' value='true'></param>"
		+ "<embed src='" + actualID + "&autoplay=1' type='application/x-shockwave-flash' allowfullscreen='true' autostart='true' width='425' height='344'></embed>"
		+ "</object>"

		+ "</div>"
		+ "</div>"
		+ "</div>"
		+ "<hr style='color:#3399cc'/>";
		dwr.util.byId("avSearchResult").innerHTML += htmlString;
	}
}
function searchForResourcesFinishedQueue(searchResults){
	dwr.util.byId("resourceQueue").innerHTML = "";
	if (searchResults.length == 0) dwr.util.byId("resourceQueue").innerHTML = "- sry, no results -";	
	for (i=0; i<searchResults.length; i++){
		var htmlString = "";
		var actualID = searchResults[i].resultID;
		htmlString += "<div id='" + actualID + "'";
		if ((i%2)==0){ 
			htmlString += " class='searchResultT'";
		}
		else {
			htmlString += " class='searchResultB'";
		}
		htmlString += " style='position:relative;'"
		+ " onmousedown='mouseDownOnSearchResult()'"
		+ " onmouseup='mouseUpOnSearchResult(\"" + searchResults[i].url + "\")'"
		+ " onmouseout='mouseOutOfSearchResult()'"
		+ ">"
		+ "<a href='#'"
		+ " onmouseover='openhtmlPrevInit(this, \"" + searchResults[i].url + "\", \"" + actualID + "\")'"
		+ "id='iframetest' class='highslide'>"
		+ searchResults[i].name
		+ "</a>"
		+ "<div class='highslide-html-content' id='htmlPrev' style='padding:0'>"
		+ "<div class='highslide-move html-header' style='border: 0'>"
    	+ "<a href='#' onclick='return hs.close(this)' class='control'>Close</a>"
	    + "</div>"
		+ "<div class='highslide-body'></div>"
		+ "</div>"
		+ "</div>"
		+ "<hr style='color:#3399cc'/>";
		dwr.util.byId("resourceQueue").innerHTML += htmlString;
	}
}

var currentDraggable;
var showPreview = true;
var previewCounter = 0;
var myPreviewCounter = 0;
var globalthis;
function openImagePrevInit(tmpthis, imgsrc, srcID){
	if (currentDraggable) currentDraggable.destroy();
	currentDraggable = new Draggable(srcID , {revert: true, scroll: window});
	globalthis = tmpthis;
	if (previewCounter > 1000){
		previewCouter = 0;
	}
	previewCounter += 1;
	var myPreviewCounter = previewCounter;
	window.setTimeout("openImagePrev('"+ imgsrc +"', '"+ srcID +"', '"+ myPreviewCounter +"')", 800);
}

function openImagePrev(imgsrc, srcID, myPreviewCounter) {
	if (dwr.util.getValue("showPreviewCheck") && myPreviewCounter == previewCounter){
		if (!isMouseDownOnSearchResult) currOpendExp = hs.expand(globalthis, { src: imgsrc });
  	}
}

function openhtmlPrevInit(tmpthis, htmlsrc, srcID) {
	if (currentDraggable) currentDraggable.destroy();
	currentDraggable = new Draggable(srcID , {revert: true, scroll: window});
	globalthis = tmpthis;
	if (previewCounter!=(myPreviewCounter+3)){
		hs.closeAll(currOpendExp);
	}
	if (previewCounter > 1000){
		previewCouter = 0;
	}
	previewCounter += 1;
	var myPreviewCounter = previewCounter;
	window.setTimeout("openhtmlPrev('"+ htmlsrc +"', '"+ srcID +"', '"+ myPreviewCounter +"')", 800);
}

function openhtmlPrev(htmlsrc, srcID, myPreviewCounter) {
	if (dwr.util.getValue("showPreviewCheck") && myPreviewCounter == previewCounter){
		if (!isMouseDownOnSearchResult) {
			currOpendExp = hs.htmlExpand(globalthis, { src: htmlsrc, contentId: 'htmlPrev', objectType: 'iframe',
			objectWidth: 1050, minWidth: 500, objectHeight: 400, objectLoadTime: 'before', allowWidthReduction: 1} );
		}
   	}
}

function openMMPrevInit(tmpthis, srcID) {
	if (currentDraggable) currentDraggable.destroy();
	currentDraggable = new Draggable(srcID , {revert: true, scroll: window});
	globalthis = tmpthis;
	if (previewCounter!=(myPreviewCounter+3)){
		hs.closeAll(currOpendExp);
	}
	if (previewCounter > 1000){
		previewCouter = 0;
	}
	previewCounter += 1;
	var myPreviewCounter = previewCounter;
	window.setTimeout("openMMPrev('"+ srcID +"', '"+ myPreviewCounter +"')", 800);
}

function openMMPrev(srcID, myPreviewCounter){
	if (dwr.util.getValue("showPreviewCheck") && myPreviewCounter == previewCounter){
		if (!isMouseDownOnSearchResult) {
			currOpendExp = hs.htmlExpand(globalthis, { contentId: srcID +'_content', outlineType: 'rounded-white', outlineWhileAnimating: true, minWidth: 444 } ); 
		}
   	}
}

function mouseDownOnSearchResult(){
	isMouseDownOnSearchResult = true; 
	hs.closeAll(-1);
	manualClickIndicator = true;
	setTimeout("manualClickHandler()", 100);
}

function manualClickHandler(){
	manualClickIndicator = false;
}

function mouseUpOnSearchResult(url){
	isMouseDownOnSearchResult = false;
	if (manualClickIndicator) {
		window.open(url, "_blank");	
	}
}

function mouseOutOfSearchResult(){
	previewCounter += 1;
}

function mouseOutOfImageSearchResult(){
	hs.closeAll(currOpendExp);
	previewCounter += 1;
}

/**
 * This method is invoked whenever an item/element is dropped into the Group area
 * which happens if (a) a new SearchResult is added to the group (element.class = searchResult)
 * and (b) if resources are moved within the Group area 
 *
 * @param element the element that is dragged into the area
 * @param dropon the element on which the item is dropped (thus this should be the Group area)
 * @param event the corresponding mouse event
 */
	function itemDropped(element, dropon, event) {
		if(Element.hasClassName(element.id, 'searchResult')
				||Element.hasClassName(element.id, 'searchResultT')
				||Element.hasClassName(element.id, 'searchResultB')){
			var layer = null;  
			layer = dwr.util.byId(element.id);  
   			DWRGroupManager.addSearchResultToGroup(element.id, $('mainGroupWindow').offsetLeft + layer.offsetLeft + 660, layer.offsetTop, layer.offsetWidth, 160, zAxisIndicator+1, $('group').offsetWidth, $('group').offsetHeight, loadResourceIntoGroup);
   			var opacity = new Effect.Opacity(element, {duration:1.0, from:1.0, to:0.3, delay: 1.2});
		}
	}
//-->
</script>